package com.wantong.jianpu.models;

import android.app.Person;

import com.trello.rxlifecycle2.LifecycleProvider;
import com.wantong.jianpu.beans.DeviceBean;
import com.wantong.jianpu.beans.DictBean;
import com.wantong.jianpu.beans.FaultDetailBean;
import com.wantong.jianpu.beans.FaultListBean;
import com.wantong.jianpu.beans.LoginBean;
import com.wantong.jianpu.beans.MeasuresSelectBean;
import com.wantong.jianpu.beans.PersonBean;
import com.wantong.jianpu.beans.RankBean;
import com.wantong.jianpu.beans.StatusBean;
import com.wantong.jianpu.net.BaseObserver;
import com.wantong.jianpu.net.HttpUtils;
import com.wantong.jianpu.net.RetrofitUtil;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import me.goldze.mvvmhabit.base.BaseModel;

/**
 * @author PACY
 * @date 2022/5/23
 * description:
 */
public class FaultModel extends BaseModel {
    /**
     *  维修等级
     * @param observer
     * @param lifecycle
     */
    public void rankList( BaseObserver<List<RankBean>> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().rankList();
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  维修人员
     * @param observer
     * @param lifecycle
     */
    public void userList(BaseObserver<List<PersonBean>> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().userList();
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  维修状态
     * @param observer
     * @param lifecycle
     */
    public void statusList(BaseObserver<List<StatusBean>> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().statusList();
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  维修列表
     * @param observer
     * @param lifecycle
     */
    public void faultList(Map<String,Object> params, BaseObserver<FaultListBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().faultList(params);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  通过位置查询设备列表
     * @param observer
     * @param lifecycle
     */
    public void getEquListByLocation(int locationId, BaseObserver<List<DeviceBean>> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().getEquListByLocation(locationId);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }


    /**
     *  故障上报
     * @param observer
     * @param lifecycle
     */
    public void commitRepair(String params, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().commitRepair(HttpUtils.buildBody(params));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  故障修改
     * @param observer
     * @param lifecycle
     */
    public void changeRepair(String params, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().changeRepair(HttpUtils.buildBody(params));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  查询报修详情
     * @param observer
     * @param lifecycle
     */
    public void getRepairDetail(String id, BaseObserver<FaultDetailBean> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().getRepairDetail(id);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  查询报修详情状态
     * @param observer
     * @param lifecycle
     */
    public void getRepairDetailStatus(String id, BaseObserver<Integer> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().getRepairDetailStatus(id);
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }


    /**
     *  指派维修人员
     * @param observer
     * @param lifecycle
     */
    public void dispatch(Map<String,Object> params, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().dispatch(HttpUtils.buildBody(params));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  故障分析下拉
     * @param observer
     * @param lifecycle
     */
    public void listAll(BaseObserver<List<MeasuresSelectBean>> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().listAll();
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  维修提交
     * @param observer
     * @param lifecycle
     */
    public void commitRepairProgress(Map<String,Object> params, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().commitRepairProgress(HttpUtils.buildBody(params));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  维修提交
     * @param observer
     * @param lifecycle
     */
    public void repairConfirm(Map<String,Object> params, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().repairConfirm(HttpUtils.buildBody(params));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  工单确认提交
     * @param observer
     * @param lifecycle
     */
    public void order_submit(Map<String,Object> params, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().order_submit(HttpUtils.buildBody(params));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }

    /**
     *  工单退回
     * @param observer
     * @param lifecycle
     */
    public void gdth(Map<String,Object> params, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().gdth(HttpUtils.buildBody(params));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }


    /**
     *  保养范围
     * @param observer
     * @param lifecycle
     */
    public void scope(BaseObserver<List<DictBean>> observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().scope();
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }


    /**
     *  巡检
     * @param observer
     * @param lifecycle
     */
    public void inspection_record(String params, BaseObserver observer, LifecycleProvider lifecycle) {
        Observable observable = RetrofitUtil.getApiService().inspection_record(HttpUtils.buildBody(params));
        RetrofitUtil.composeToSubscribe(observable, observer, lifecycle);
    }
}
